package com.example.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplus.model.domain.Division;
import com.example.mybatisplus.model.domain.Regiment;
import com.example.mybatisplus.mapper.RegimentMapper;
import com.example.mybatisplus.model.dto.PageDTO;
import com.example.mybatisplus.service.RegimentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lxp
 * @since 2023-01-01
 */
@Service
public class RegimentServiceImpl extends ServiceImpl<RegimentMapper, Regiment> implements RegimentService {


    @Autowired
    private RegimentMapper regimentMapper;

    @Override
    public Page<Regiment> regList(Regiment regiment, PageDTO pageDTO) {
        Page<Regiment> page = new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize());
        QueryWrapper<Regiment> wrapper = new QueryWrapper<>();
        if (regiment.getRegiment() != null){
            wrapper.like("regiment", regiment.getRegiment());
        }
        Page<Regiment> regimentPage = regimentMapper.selectPage(page, wrapper);
        return regimentPage;
    }
}
